﻿using System;
using System.Xml;

namespace CDude.Vita
{
    internal class RandomText
    {
        public double FontSize;
        public string Text;

        public RandomText(double fontsize, string text)
        {
            this.FontSize = fontsize;
            this.Text = text;
        }

        public RandomText(string url)
        {
            using (XmlTextReader xmlreader = new XmlTextReader(url) { XmlResolver = null })
            {
                string nodename = null;
                while (xmlreader.Read())
                {
                    switch (xmlreader.NodeType)
                    {
                        case XmlNodeType.Element:
                            nodename = xmlreader.Name;
                            break;

                        case XmlNodeType.Text:
                            switch (nodename)
                            {
                                case "FontSize":
                                    this.FontSize = Convert.ToDouble(xmlreader.Value.Remove(xmlreader.Value.IndexOf(".")));
                                    break;

                                case "Text":
                                    this.Text = xmlreader.Value;
                                    break;
                            }
                            break;
                    }
                }
            }
        }
    }
}